import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;

public class TweetMessage {
	
	TweetMessage(){}

	public boolean tweet(String message){

		try{
			TwitterFactory factory = new TwitterFactory();
			Twitter twitter = factory.getInstance();

			twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
			
			AccessToken accessToken = loadAccessToken();
			twitter.setOAuthAccessToken(accessToken);
			Status status = twitter.updateStatus(message);
		    return true;
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	private static AccessToken loadAccessToken(){
	    String token = "[user token]";
	    String tokenSecret = "[user tokensecret]";
	    return new AccessToken(token, tokenSecret);
	  }
	

}
